package A.reflection2;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Properties;

public class Demo {
    public static void main(String[] args) throws IOException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        Class<?> cls = Class.forName(getValue("className"));
        Method methodName = cls.getMethod(getValue("methodName"));
        methodName.invoke(cls.getConstructor().newInstance());
    }

    public static String getValue(String key) throws IOException {
        Properties properties = new Properties();
        properties.load(new FileInputStream("src\\A\\reflection2\\stu.properties"));
        return properties.getProperty(key);
    }
}
